package com.cn.ctrl

import com.cn.model.Users
import com.cn.serv.UserService
import org.springframework.web.bind.annotation.*
import javax.annotation.Resource

@RestController
@RequestMapping("users")
class UsersController {

    @Resource
    private lateinit var userService: UserService

    @GetMapping("tt")
    fun test(): String {
        return userService.test()
    }

    @PostMapping("add")
    fun saveUser(@RequestBody user: Users): Int {
        println("---------------------")
        println(user)
        println("************************")
        return userService.add(user)
    }

    @GetMapping("getById")
    fun getUserById(@PathVariable id: Long): Users? {
        return userService.getUserById(id)
    }

    @GetMapping("getList")
    fun getAllUsers(): List<Users>? {
        return userService.getAllUsers()
    }
}